﻿@{
    ViewBag.Title = "adminOrderList";
}

<div id="cphMain_ctl00_ContentPane" class="center">
    <div id="Breadcrumb" class="Breadcrumb">
        <ul>
            <li class="first">
                <a href='javascript:;' onclick="javascript:loadAction('Index2','Main')">
                    Trang chủ
                </a>
            </li>
            <li>
                <a href='javascript:;' onclick="javascript:loadAction('personal','Account')">
                    Tài khoản của tôi
                </a>
            </li>            
            <li>
                <span>Danh sách đơn hàng</span>
            </li>
        </ul>
    </div>

<div class="Account-Module DefaultModule">
    
<div class="Block DefaultModule">
    

    <div id="CartHeader" class="Block Moveable Panel">
        <h2>
            Danh sách đơn hàng
        </h2>
    </div>

    <div id="CartContainer" class="Block Moveable Panel">

        <div class="BlockContent">
            @if (ViewBag.orderList != null)
            {                
                    <div class="Clear">
                    </div>

                    <div>
                        <div>

                            <table class="CartContents" cellspacing="0" rules="rows" border="1" 
                                id="cphMain_ctl00_ctl01_ctl00_grvList" style="width: 100%; 
                                        border-collapse: collapse;">
                                <tbody>
                                    <tr class="even-row">
                                        <th  scope="col" style="text-align:left">Mã đơn hàng
                                        </th>
                                        <th scope="col" style="text-align:left" >
                                            Ngày đặt hàng
                                        </th>
                                        <th scope="col" style="text-align:left" >
                                            Tên khách hàng
                                        </th>
                                        <th scope="col" style="text-align:right" >
                                            Số điện thoại
                                        </th>
                                        <th  scope="col" style="text-align:right">Tổng số tiền
                                        </th>                                        
                                        <th scope="col" style="text-align:center">Trạng thái
                                        </th>
                                        <th scope="col">&nbsp;</th>
                                    </tr>
                                    @{var rowCount = 0; string cssRowClass = "";}
                                    @foreach (var order in ViewBag.orderList)
                                    {
                                        if (++rowCount % 2 == 1) { cssRowClass = "old-row"; }
                                        else { cssRowClass = "even-row"; }
                                        <tr class="@cssRowClass">
                                            <td style="text-align:center">
                                                <a href="javascript:;" onclick="javascript:loadActionData('CustomerOrderDetailList','Account','orderID=@order.ID')">
                                                    <strong>@order.ID</strong></a>                                                
                                                <br>                                                                                                
                                            </td>
                                            <td >
                                                @order.order_date
                                            </td>                                            
                                            <td >
                                                <a href="javascript:;" onclick="javascript:viewAccountDetail(@order.customer_ID)">
                                                    <b>@order.Account.username</b>
                                                </a>                                                
                                            </td>
                                            <td>
                                                @order.Account.phone_number
                                            </td>
                                            <td style="width: 100px; text-align:right">                                                
                                                <span>@Convert.ToInt32(order.total)</span>
                                            </td>                    
                                            <td style="width: 100px; text-align:center">                                                                                                
                                                @{var status = new string[] { "waiting", "processing", "closed" };}
                                                <select id="status" style="width:100px" onchange="javascript:OnStatusChange(this,@order.ID)">
                                                @foreach (var stt in status)
                                                {
                                                    if(stt == order.status)
                                                    {<option selected="selected">@stt</option>}    
                                                    else{<option>@stt</option>}
                                                }
                                                </select>                                                
                                            </td>                        
                                            <td  style="width: 1px;">
                                                @{var cssClass = "myBtn2";
                                                  if (order.status == "waiting")
                                                  {
                                                      cssClass = "myBtn1";
                                                  }                                                  
                                                  }
                                                <div style="margin-bottom: 10px;">
                                                <a href="javascript:;" onclick="javascript:removeOrder(@order.customer_ID,@order.ID)" 
                                                    class="@cssClass">Xóa</a>
                                                </div>
                                                <a href="javascript:;" onclick="javascript:sendSMS(@order.ID)" 
                                                    class="@cssClass">SMS</a>
                                            </td>
                                        </tr>
                                    }
                                </tbody>
                            </table>

                        </div>

                    </div>       
                
                                            <div class="PageNavigation" style="padding-bottom: 10px; padding-top: 10px;" align="center">
            @{var previousPage = Math.Max(ViewBag.currentPage-1, 1);}
            <a  href="javascript:;" onclick="javascript:loadActionData('adminOrderList','Admin','pageNum=@previousPage')">&lt;&lt;</a>    
            @for(int num = 1; num <= ViewBag.maxPage; num ++)
            {
               if(ViewBag.currentPage == num)
               {
                  <a class="active" href="#" 
                      style="background-color:gray;color:white;"><strong>@num</strong></a>
                }
                else
                {
                   <a  href="javascript:;" onclick="javascript:loadActionData('adminOrderList','Admin','pageNum=@num')">@num</a>    
                }
            }                   
            @{var nextPage = Math.Min(ViewBag.maxPage, ViewBag.currentPage + 1);}
            <a href="javascript:;" onclick="javascript:loadActionData('adminOrderList','Admin','pageNum=@nextPage')">&gt;&gt;</a>    
        </div>
                             
            }else
            {
                <div>
                    Bạn chưa có đơn hàng nào!
                </div>

                <div class="Clear">
                </div>
            }
            
        </div>
    </div>        
</div>


</div>
</div>

